#ifndef __LIB_KERNEL_IO_H
#define __LIB_KERNEL_IO_H

#include "stdint.h"

static inline void io_out_byte(uint16_t port, uint8_t byte){
   asm volatile ( "outb %b0, %w1" : : "a" (byte), "Nd" (port));    
}

static inline void io_out_bytes(uint16_t port, void* bytes, uint32_t count){
   asm volatile ("cld; rep outsw" : "+S" (bytes), "+c" (count) : "d" (port));
}

static inline uint8_t io_in_byte(uint16_t port){
    uint8_t _ret_byte;
    asm volatile("inb %w1, %b0" : "=a"(_ret_byte) : "Nd"(port));
    return _ret_byte;
}

static inline void io_in_bytes(uint16_t port, void* bytes, uint32_t count){
    asm volatile("cld; rep insw" : "+D"(bytes), "+c"(count) : "Nd"(port) : "memory"); 
}

#endif 
